package com.betterjr.modules.application.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.modules.application.data.ApplicationCustRoleConstantCollections;

/**
 * 
 * @ClassName: ApplicaitonCustRole 
 * @Description: 企业角色对应应用表
 * @author xuyp
 * @date 2017年11月17日 上午11:33:41 
 *
 */
@Access(AccessType.FIELD)
@Entity
@Table(name = "t_ams_application_custrole")
public class ApplicaitonCustRole extends ApplicationOperorg {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -8681822113986342527L;

    /**
     * 企业编号
     */
    @Column(name = "l_custno", columnDefinition = "INTEGER")
    @MetaData(value = "企业编号", comments = "企业编号")
    private Long custNo;

    /**
     * 企业名称
     */
    @Column(name = "c_custname", columnDefinition = "VARCHAR")
    @MetaData(value = "企业名称", comments = "企业名称")
    private String custName;

    /**
     * 角色id
     */
    @Column(name = "l_role_id", columnDefinition = "INTEGER")
    @MetaData(value = "角色id", comments = "角色id")
    private Long roleId;

    /**
     * 角色名称
     */
    @Column(name = "c_role_name", columnDefinition = "VARCHAR")
    @MetaData(value = "角色名称", comments = "角色名称")
    private String roleName;

    public Long getCustNo() {
        return custNo;
    }

    public void setCustNo(Long custNo) {
        this.custNo = custNo;
    }

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((custName == null) ? 0 : custName.hashCode());
        result = prime * result + ((custNo == null) ? 0 : custNo.hashCode());
        result = prime * result + ((roleId == null) ? 0 : roleId.hashCode());
        result = prime * result + ((roleName == null) ? 0 : roleName.hashCode());
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getApplicationId() == null) ? 0 : getApplicationId().hashCode());
        result = prime * result + ((getOperOrg() == null) ? 0 : getOperOrg().hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!super.equals(obj)) return false;
        if (getClass() != obj.getClass()) return false;
        ApplicaitonCustRole other = (ApplicaitonCustRole) obj;
        if (custName == null) {
            if (other.custName != null) return false;
        } else if (!custName.equals(other.custName)) return false;
        if (custNo == null) {
            if (other.custNo != null) return false;
        } else if (!custNo.equals(other.custNo)) return false;
        if (roleId == null) {
            if (other.roleId != null) return false;
        } else if (!roleId.equals(other.roleId)) return false;
        if (roleName == null) {
            if (other.roleName != null) return false;
        } else if (!roleName.equals(other.roleName)) return false;
        if (getId() == null) {
            if (other.getId() != null) return false;
        } else if (!getId().equals(other.getId())) return false;
        if (getApplicationId() == null) {
            if (other.getApplicationId() != null) return false;
        } else if (!getApplicationId().equals(other.getApplicationId())) return false;
        if (getOperOrg() == null) {
            if (other.getOperOrg() != null) return false;
        } else if (!getOperOrg().equals(other.getOperOrg())) return false;

        return true;
    }

    @Override
    public String toString() {
        return "ApplicaitonCustRole [custNo=" + custNo + ", custName=" + custName + ", roleId=" + roleId + ", roleName="
                + roleName + ", getId()=" + getId() + ", getApplicationId()=" + getApplicationId() + ", getOperOrg()="
                + getOperOrg() + ", getBusinStatus()=" + getBusinStatus() + ", getApplicationGroupId()="
                + getApplicationGroupId() + ", getApplicationTypeId()=" + getApplicationTypeId()
                + ", getApplicationName()=" + getApplicationName() + ", getApplicationGroupName()="
                + getApplicationGroupName() + "]";
    }

    public void saveAddValue() {

        this.setBusinStatus(ApplicationCustRoleConstantCollections.APPLICATIONCUSTROLE_BUSINSTATUS_EFFECTIVE);
        this.setId(SerialGenerator.getLongValue("ApplicaitonCustRole.id"));

    }

}
